package com.lucas.rpc.server;

import com.lucas.rpc.api.interfaces.HelloService;
import com.lucas.rpc.framework.entity.URL;
import com.lucas.rpc.framework.server.multiversion.LocalRegister;
import com.lucas.rpc.framework.server.register.FakeRemoteRegister;
import com.lucas.rpc.framework.transport.socket.SocketRpcServer;

import java.net.InetAddress;

/**
 * @author: LiuCheng
 * @description:
 * @date: 2023-12-04 15:49
 **/
public class SocketServerMain {

    public static void main(String[] args) throws Exception{

        //本地注册接口和不同版本的的实现类
        LocalRegister.register(HelloService.class.getName(),"1.0", HelloServiceImpl.class);
        LocalRegister.register(HelloService.class.getName(),"2.0", HelloServiceImpl2.class);

        //远程注册provider的地址
        URL url = new URL(InetAddress.getLocalHost().getHostAddress(), 8080);
        FakeRemoteRegister.register(HelloService.class.getName(),url);


        SocketRpcServer socketRpcServer = new SocketRpcServer();
        socketRpcServer.start();
    }

}
